package com.creawor.hz_market.resource.age_resource;

import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;

import com.creawor.hz_market.servlet.LoadMapInfoAjax;
import com.creawor.imei.base.AbsQueryMap;

public class AgeResource_QueryMap extends AbsQueryMap {
	private static final Logger logger = Logger.getLogger(LoadMapInfoAjax.class);
public AgeResource_QueryMap() throws HibernateException {
	this.initSession();
}

public Iterator findAll() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from AgeResource").next()).intValue();
	String querystr = "from AgeResource";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.iterate();
}
public List findAllList() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from AgeResource").next()).intValue();
	String querystr = "from AgeResource";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.list();
}
public List findAllByCounty(String county) throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from AgeResource where county ='"+county+"'").next()).intValue();
	String querystr = "from AgeResource as t where t.county ='"+county+"'";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.list();
}

public AgeResource_Form getByID(String ID) throws HibernateException {
	AgeResource_Form  vo = null;

//System.out.println("\nt_group_QueryMap getByID:"+ID);
logger.debug("\nAgeResource_QueryMap getByID:"+ID);

	this.session.clear();
	try {
		vo =new AgeResource_Form();
		AgeResource po=(AgeResource) this.session.load(AgeResource.class, new Integer(ID));

try{
  vo.setId(String.valueOf(po.getId()));
}catch (Exception e) {
	    e.printStackTrace();
}
vo.setType(po.getType());
vo.setCompany(po.getCompany());
/*try{
	vo.setZhengshi(String.valueOf(po.getZhengshi()));
}catch (Exception e) {
    e.printStackTrace();
}
try{
	vo.setLaowu(String.valueOf(po.getLaowu()));
}catch (Exception e) {
    e.printStackTrace();
}*/
try{
	vo.setAverage(String.valueOf(po.getAverage()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setXiaoyu35(String.valueOf(po.getXiaoyu35()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setDayu35(String.valueOf(po.getDayu35()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
	/*try{
	vo.setYanjius(String.valueOf(po.getYanjius()));
	}catch (Exception e) {
	    e.printStackTrace();
	}

try{
	vo.setBenkes(String.valueOf(po.getBenkes()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setDazhuan(String.valueOf(po.getDazhuan()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setGaozhong(String.valueOf(po.getGaozhong()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setChuzhong(String.valueOf(po.getChuzhong()));
	}catch (Exception e) {
	    e.printStackTrace();
	}*/
try{
	    vo.setUpdatedDay(com.creawor.km.util.DateUtil.getStr(po.getUpdatedDay(),"yyyy-MM-dd"));
	    vo.setInsertDay(com.creawor.km.util.DateUtil.getStr(po.getInsertDay(),"yyyy-MM-dd"));
	  }catch (Exception e) {
		    e.printStackTrace();
	  }



	} catch (HibernateException e) {
		
		logger.debug("\nERROR in getByID @employeeresource:" + e);
	}
	return vo;
}	

}
//����������


